# to make and install run:
# make all ifirefox

all: clean firefox chrome

.PHONY: chrome

chrome:
	rm -rf ./chrome/build/
	mkdir -p ./chrome/build/
	cp ./chrome/manifest.json ./chrome/build/
	cp -r ./chrome/injection ./chrome/build/
	cp -r ./common/ ./chrome/build/

.PHONY: firefox

firefox:
	rm -rf ./firefox/build/
	mkdir -p ./firefox/build/
	cp ./firefox/chrome.manifest ./firefox/build/
	cp ./firefox/install.rdf ./firefox/build/
	cp -r ./firefox/*.js ./firefox/build/
	cp -r ./firefox/*.xul ./firefox/build/
	cp -r ./firefox/injection ./firefox/build/
	cp -r ./common/* ./firefox/build/

	(cd ./firefox/build/; rm ../../mircle.xpi; zip -r ../../mircle.xpi *)

UNAME = $(shell uname)

ifirefox:
ifeq ($(UNAME), Darwin)
	mkdir -p ~/Library/Application\ Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
	cp mircle.xpi ~/Library/Application\ Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/{28921E07-1955-4827-96E4-AAC6F6A3A96C}.xpi
endif
ifeq ($(UNAME), Linux)
	mkdir -p ~/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
	cp mircle.xpi ~/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/{28921E07-1955-4827-96E4-AAC6F6A3A96C}.xpi
endif

open:
	open /Library/Internet\ Plug-Ins/
	open /Library/Application\ Support/Mozilla/
	open ~/Library/Internet\ Plug-Ins/
	open ~/Library/Application\ Support/Mozilla/

clean:
	rm -rf mircle.xpi
	rm -rf ./firefox/build/
	rm -rf ./chrome/build/
